//
//  CAHBJLHeaderView.m
//  LNH
//
//  Created by twentylx on 2018/1/26.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAHBJLHeaderView.h"

@implementation CAHBJLHeaderView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.allButton];
    [self addSubview:self.oneButton];
    [self addSubview:self.twoButton];
    [self addSubview:self.threeButton];
    [self addSubview:self.lineView];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_allButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.centerY.equalTo(self);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_oneButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.allButton.mas_right).offset(20);
        make.centerY.equalTo(self);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_twoButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.oneButton.mas_right).offset(20);
        make.centerY.equalTo(self);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_threeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.twoButton.mas_right).offset(20);
        make.centerY.equalTo(self);
        make.width.mas_equalTo((SCREEN_WIDTH - 100)/4);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.bottom.equalTo(self);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
}

#pragma mark get & set
- (UIButton *)allButton {
    if (!_allButton) {
        _allButton = [UIButton new];
        [_allButton setTitle:@"全部" forState:UIControlStateNormal];
        [_allButton setTitleColor:RGBCOLOR(89, 89, 89) forState:UIControlStateNormal];
        [_allButton setTitleColor:RGBCOLOR(212, 98, 50) forState:UIControlStateSelected];
        _allButton.titleLabel.font = [UIFont systemFontOfSize:14];
        _allButton.layer.borderWidth = 1;
        _allButton.layer.cornerRadius = 5;
        _allButton.layer.borderColor = [RGBCOLOR(212, 98, 50) CGColor];
        _allButton.selected = YES;
    }
    return _allButton;
}

- (UIButton *)oneButton {
    if (!_oneButton) {
        _oneButton = [UIButton new];
        [_oneButton setTitle:@"第一消费者" forState:UIControlStateNormal];
        [_oneButton setTitleColor:RGBCOLOR(89, 89, 89) forState:UIControlStateNormal];
        [_oneButton setTitleColor:RGBCOLOR(212, 98, 50) forState:UIControlStateSelected];
        _oneButton.titleLabel.font = [UIFont systemFontOfSize:14];
        _oneButton.layer.borderWidth = 1;
        _oneButton.layer.cornerRadius = 5;
        _oneButton.layer.borderColor = [RGBCOLOR(241, 241, 241) CGColor];
    }
    return _oneButton;
}

- (UIButton *)twoButton {
    if (!_twoButton) {
        _twoButton = [UIButton new];
        [_twoButton setTitle:@"第二消费者" forState:UIControlStateNormal];
        [_twoButton setTitleColor:RGBCOLOR(89, 89, 89) forState:UIControlStateNormal];
        [_twoButton setTitleColor:RGBCOLOR(212, 98, 50) forState:UIControlStateSelected];
        _twoButton.titleLabel.font = [UIFont systemFontOfSize:14];
        _twoButton.layer.borderWidth = 1;
        _twoButton.layer.cornerRadius = 5;
        _twoButton.layer.borderColor = [RGBCOLOR(241, 241, 241) CGColor];
    }
    return _twoButton;
}

- (UIButton *)threeButton {
    if (!_threeButton) {
        _threeButton = [UIButton new];
        [_threeButton setTitle:@"团队业绩" forState:UIControlStateNormal];
        [_threeButton setTitleColor:RGBCOLOR(89, 89, 89) forState:UIControlStateNormal];
        [_threeButton setTitleColor:RGBCOLOR(212, 98, 50) forState:UIControlStateSelected];
        _threeButton.titleLabel.font = [UIFont systemFontOfSize:14];
        _threeButton.layer.borderWidth = 1;
        _threeButton.layer.cornerRadius = 5;
        _threeButton.layer.borderColor = [RGBCOLOR(241, 241, 241) CGColor];
    }
    return _threeButton;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = RGBCOLOR(51, 51, 51);
    }
    return _lineView;
}

@end
